package com.example.telesys.controller;

import com.example.telesys.TrafficService;
import com.example.telesys.pojo.ApiResponse;
import com.example.telesys.pojo.StatusCode;
import com.example.telesys.pojo.StatusMessage;
import com.example.telesys.pojo.Traffic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/traffic")
public class TrafficController {

    @Autowired
    private TrafficService trafficService;

    @RequestMapping("/selectAllTraffic")
    public ApiResponse selectAllTraffic(){
        List<Traffic> trafficList = trafficService.selectAllTraffic();
        return new ApiResponse(StatusCode.SUCCESS, StatusMessage.SUCCESS, trafficList);
    }

    @RequestMapping("/selectTrafficById")
    public ApiResponse selectTrafficById(@RequestParam("trafficid")String trafficid){
        Traffic traffic =  trafficService.selectTrafficById(trafficid);
        return new ApiResponse(StatusCode.SUCCESS, StatusMessage.SUCCESS, traffic);
    }
}
